<template>
  <svg :class="svgClass" aria-hidden="true">
    <use :xlink:href="iconName" />
  </svg>
</template>

<script setup lang="ts">
import { computed } from 'vue'
const props = defineProps({ icon: String })
const iconName = computed(() => `#${props.icon}`)
const svgClass = computed(() => `svg-icon icon-${props.icon}`)
</script>

<style scoped lang="scss">
.svg-icon {
  width: 1em;
  height: 1em;
  fill: currentColor; /* 让 el-icon 的 color prop 生效 */
}
</style>
